<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'adminlogin.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    
    <!-- CSS -->
        <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
        <link rel="stylesheet" href="assets/css/reset.css">
        <link rel="stylesheet" href="assets/css/supersized.css">
        <link rel="stylesheet" href="assets/css/style.css">

        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
    
<script type="text/javascript">
  var code ; //在全局 定义验证码      
function createCode(){ //定义验证码的 函数
code = "";//开始验证码为空
var codeLength = 3;//验证码的长度      
var checkCode = document.getElementById("checkCode");//通过Id获取验证码的值   
checkCode.value = ""; //将验证码定义为空值
var selectChar = new Array(1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','j','k','l','m','n','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z');      
      
for(var i=0;i<codeLength;i++) {      
 var charIndex = Math.floor(Math.random()*60);      
code +=selectChar[charIndex];      
}      
if(code.length != codeLength){      
  createCode();      
}      
checkCode.value = code;      
}      
      
     
function validate () {      
var inputCode = document.getElementById("input1").value.toUpperCase();      
var codeToUp=code.toUpperCase();  
if(inputCode.length <=0) {      
  alert("请输入验证码！");      
  return false;      
}      
else if(inputCode != codeToUp ){      
   alert("验证码输入错误！");      
   createCode();      
   return false;      
}      
else
{
alert("通过验证！");
return true;
}
      
}         
   </script>

  </head>
  
  <body onload="createCode();">
   <div class="officialcar"><br>
     <h1>管理员登录</h1>
            <form action="servlet/admin" method="post">
                <input type="text" name="adminName" value="admin"class="username" placeholder="用户名">
                <input type="password" name="adminPassword" value="123456"class="password" placeholder="密码">
                <input type="text" id="input1" placeholder="验证码"/>   
   <input type="text" id="checkCode" class="code" style="width: 60px" /> <a href="admin/adminlogin.jsp" onclick="createCode()">看不清楚</a>      
      <input id="Button1" onclick="validate();" type="button" value="确定" />
                <button type="submit">登录</button>
                <div class="error"><span>+</span></div>
            </form>
  
   </div>
   
   <!-- Javascript -->
        <script src="assets/js/jquery-1.10.2.min.js"></script>
        <script src="assets/js/supersized.3.2.7.min.js"></script>
        <script src="assets/js/supersized-init.js"></script>
        <script src="assets/js/scripts.js"></script>
        
   
   
  </body>
</html>
